/**
 * 斐波那契数列(黄金分割数列)，第0项为0，第1项为1，第2项为1,后面的每一项都是前面两项的和
*/
//第N项的值
const FeiBoN = (n)=>{
    if(n<=1) return n
    return FeiBoN(n-1) + FeiBoN(n-2)
}
const FeiBoN1 = (n)=>{
    const arr = [0,1]
    for(let i=2;i<=n;i++){
        arr[i] = arr[i-1]+arr[i-2]
    }
    return arr[n]
}
console.log(FeiBoN(6)) //8  [0,1,1,2,3,5,8]
console.log(FeiBoN1(6)) //8


//第N个数的总和
const FeiBoNTotal = (n)=>{
    let total = 0
    for(let j=0;j<=n;j++){
        total+=FeiBoN(j)
    }
    return total
}
console.log(FeiBoNTotal(6))